﻿using System;
using UnityEngine;
using PluginManager.Plugin;
using System.Collections;
using UnityEngine.SceneManagement;
using ShooterGameMOD_Besiege;
using ShooterGameMOD_Besiege.Player;
using System.Collections.Generic;

namespace ShooterGameMod_Besiege
{

    [OnGameInit]
    public class ShooterGameMod : MonoBehaviour
    {

        GameObject ShooterGame = new GameObject("Shooter Game");

        public ShooterGameMod()
        {
        }

        public void Start()
        {
            ShooterGame.AddComponent<WeaponScript>();
            ShooterGame.AddComponent<PlayerScript>();

            UnityEngine.Object.DontDestroyOnLoad(ShooterGame);

            SceneManager.sceneLoaded += OnSceneLoaded;
        }

        static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            Debug.Log("loaded scene" + scene.name);
            PlayerScript.playerCreated = false;

        }

        static public bool isBuilding()
        {

            List<string> scene = new List<string> { "TITLE SCREEN", "LevelSelect", "LevelSelect1", "LevelSelect2", "LevelSelect3" };


            if (SceneManager.GetActiveScene().isLoaded)
            {

                if (!scene.Exists(match => match == SceneManager.GetActiveScene().name))
                {
                    return true;
                }
            }

            return false;

        }

    }

    
}
